﻿$(function () {
    $(".approve,.reject").click(function () {
        var pid = $(this).attr("pid");
        var action = $(this).val();
        var status = "";

        if (action == "Approve") {
            status = 2;
        } else if (action == "Reject") {
            status = 3;
        }

        Ajax({
            url: "/Classifieds/UpdateStatus",
            data: JSON.stringify({ PostingID: pid, StatusID: status }),
            success: function (data) {
                if (data.Success == true) {
                    pid = data.PostingID;
                    $("#p_" + pid).fadeOut("slow");
                }
            }
        });
    });

    $(".delete").click(function () {
        var pid = $(this).attr("pid");

        if (confirm("are you sure?")) {
            Ajax({
                url: "/Classifieds/PendingDelete",
                data: JSON.stringify({ id: pid }),
                success: function (data) {
                    if (data.Success == true) {
                        pid = data.PostingID;
                        $("#p_" + pid).fadeOut("slow");
                    }
                }
            });
        }
    });
});